using System;
using System.Collections.Generic;
using System.Text;
using GraphAlgsPresentation.Core;

namespace GraphAlgsPresentation.ScriptLibrary
{
    /// <summary>
    /// Provides a reset line command
    /// </summary>
    [Serializable]
    public class ResetLine : Command
    {
        private int _indec;
        private bool isHL = false;

        /// <summary>
        /// Gets or sets the index.
        /// </summary>
        /// <value>The index.</value>
        public int Index
        {
            get { return _indec; }
            set { _indec = value; }
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="ResetLine"/> class.
        /// </summary>
        public ResetLine()
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="ResetLine"/> class.
        /// </summary>
        /// <param name="index">The index.</param>
        public ResetLine(int index)
        {
            this.Index = index;
        }

        /// <summary>
        /// Runs this instance.
        /// </summary>
        public override void Run()
        {
            if (this.Context.CommentControl.Lines[Index].BackColor != CommentLine.DefaultBackColor)
                isHL = true;
            else isHL = false;
            this.Context.CommentControl.ResetLine(this.Index);
        }

        /// <summary>
        /// Undoes this instance.
        /// </summary>
        public override void Undo()
        {
            if (isHL) this.Context.CommentControl.HighlightLine(this.Index);
        }
    }
}
